import 'package:permission_handler/permission_handler.dart';

/// 包装 permission_handler ，方便在大的版本更新时，全局替换
/// https://pub.flutter-io.cn/packages/permission_handler
class BLPermissionHelper {

  /// 检查是否授予了请求权限
  static Future<bool> checkPermissions(List<Permission> permissions) async {
    Map<Permission, PermissionStatus> statuses = await permissions.request();
    bool isAllGranted = true;
    var permissionResult = statuses.values.toList();
    //查找是否有不给权限的
    for (int i = 0; i < permissionResult.length; i++) {
      if (permissionResult[i] != PermissionStatus.granted) {
        isAllGranted = false;
        break;
      }
    }

    return isAllGranted;
  }
}